<template>
  <div class="nav">
    <div class="banxin flex">
      <h1 class="logo">
        <a href="#">
          <img src="../../assets/images/indexLogo.png" alt="" />
        </a>
      </h1>
      <ul class="router-link flex">
        <!-- <li><span class="active">首页</span></li>
        <li><span>全部商品</span></li>
        <li><span>个人中心</span></li>
        <li><span>我的订单</span></li> -->
        <li v-for="item in links" :key="item.id">
          <span
            :class="{ active: $route.path === item.path }"
            @click="$router.push(item.path)"
            >{{ item.text }}</span
          >
        </li>
      </ul>
      <div class="search-bar flex">
        <input type="text" placeholder="搜索商品" />
        <span class="btn"
          ><img src="../../assets/images/search.png" alt=""
        /></span>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      links: [
        { id: 1, text: "首页", path: "/home" },
        { id: 2, text: "全部商品", path: "/quanbusanpin" },
        { id: 3, text: "个人中心", path: "/gerenzonxin" },
        { id: 4, text: "我的订单", path: "/wodedindan" },
        { id: 5, text: "专属福利", path: "/zhuanshufuli" },
      ],
    };
  },
};
</script>
 
<style lang = "less" scoped>
.nav {
  .banxin {
    padding: 14px 0;
    justify-content: space-between;
    ul {
      padding-top: 26px;
      li {
        padding: 0 20px;
        span {
          cursor: pointer;
          font-size: 16px;
          font-family: SourceHanSansSC;
          font-weight: 700;
          color: #333;
          line-height: 23px;
          &.active {
            color: #0a328e;
          }
        }
      }
    }
    .search-bar {
      padding-top: 17px;
      height: 40px;
      input {
        box-sizing: border-box;
        height: 40px;
        width: 214px;
        border-radius: 20px 0 0 20px;
        border: 1px solid #ccc;
        border-right: 0;
        padding-left: 20px;
      }
      .btn {
        width: 50px;
        height: 40px;
        border-radius: 0 20px 20px 0;
        background: #0a328e;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
}
</style>